import { v4 as uuidv4 } from 'uuid';

//生成 usertempId
export function isUserTempId(){
    //在本地存储获取 userTempId
    let userTempId = localStorage.getItem("userTempId");
    
    if(userTempId){
        //存在 返回
        return userTempId;
    }else{
        //不存在，则生成
        let newUserTempId= uuidv4();
        // 本地存储
        localStorage.setItem("userTempId",newUserTempId);
        return newUserTempId;

    }
}




//保存 token
export function saveToken(token){
    localStorage.setItem("token",token);
}

//读取token
export function readToken(){
    return localStorage.getItem("token");
}

//删除本地token
export function deleteToken(){
    localStorage.removeItem("token");
}